#include "stdafx.h"

#include "Engine.h"

// initalization function
void InitMoveGen()
{
	InternationalMoveGen::InitBitBoardGenerator();
	CzechMoveGen::InitBitBoardGenerator();
}

 // template specialization for move generators
///////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename TBITBOARD> int MoveGenerator(SEngineData* ed, TBITBOARD* bb, bool bWhite, TBITBOARD* movelist)
{
	return  0;
}

template<> int MoveGenerator<BitBoard>(SEngineData* ed, BitBoard* bb, bool bWhite, BitBoard* movelist)
{
	return ed->MoveGenerator32Ptr(bb, bWhite, movelist);
}

template<> int MoveGenerator<BitBoard64>(SEngineData* ed, BitBoard64* bb, bool bWhite, BitBoard64* movelist)
{
	return ed->MoveGenerator64Ptr(bb, bWhite, movelist);
}


 // template specialization for TestJump function
/////////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename TBITBOARD> bool TestJump(SEngineData* ed, TBITBOARD* bb, bool bWhite)
{
	return false;
}

template<> bool TestJump<BitBoard>(SEngineData* ed, BitBoard* bb, bool bWhite)
{
	return ed->TestJump32Ptr(bb, bWhite);
}

template<> bool TestJump<BitBoard64>(SEngineData* ed, BitBoard64* bb, bool bWhite)
{
	return ed->TestJump64Ptr(bb, bWhite);
}

template<typename TBITBOARD> void ToggleMove(TBITBOARD* bb, TBITBOARD* bbMove)
{
}

template<> void ToggleMove<BitBoard>(BitBoard* bb, BitBoard* bbMove)
{
	CzechMoveGen::ToggleMove(bb, bbMove);
}

template<> void ToggleMove<BitBoard64>(BitBoard64* bb, BitBoard64* bbMove)
{
	InternationalMoveGen::ToggleMove(bb, bbMove);
}


 // checkers setting function
//////////////////////////////////////////////////

void SetCheckersTypeMoveGen(SEngineData* ed, eCheckersType type)
{
	switch(type)
	{
	case CzechCheckers:
		ed->MoveGenerator32Ptr = CzechMoveGen::GenerateBitBoardMoves;
		ed->TestJump32Ptr = CzechMoveGen::TestJump;
		break;
	case EnglishCheckers:
		ed->MoveGenerator32Ptr = EnglishMoveGen::GenerateBitBoardMoves;
		ed->TestJump32Ptr = EnglishMoveGen::TestCapture;
		break;
	case InternationalCheckers:
		ed->MoveGenerator64Ptr = InternationalMoveGen::GenerateBitBoardMoves;
		ed->TestJump64Ptr = InternationalMoveGen::TestJump;
		break;
	default:
		assert(false);
	}
}
